<script>
import store from '@/store'
	export default {
		onLaunch: function() {
			
			let navigateArr = ['navigateTo','redirectTo','reLaunch','switchTab','navigateBack']
			
			navigateArr.forEach(v=>{
				
				uni.addInterceptor(v, {
					invoke(args) {
				
						let {
							token,
							userInfo
						} = store.state.user;
				
						if (!token && args.url != '/pages/user/login') {
							args.url = '/pages/user/login'
							return true
						}
						
						//  有token   
						
						// 白名单   去的是白名单页面 放行
						
						
						let {
							mobile,
							personnel
						} = userInfo;
				
						if (mobile == 1) {
							args.url = '/pages/bind/bind'
							return true
						}
				
						if (!personnel) {
							args.url = '/pages/bind_doorplate/bind_doorplate'
							return true
						}
				
				
						return true
					},
					success(args) {
                        console.log(args)
					},
					fail(err) {
						console.log('interceptor-fail', err)
					},
					complete(res) {
						console.log('interceptor-complete', res)
					}
				})
				
				
			})
			

			
			
			
			
			
			
			
			
			
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style lang="scss">
	/*每个页面公共css */
		/* 注意要写在第一行，同时给style标签加入lang="scss"属性 */
		@import "@/uni_modules/uview-ui/index.scss";
		@import url("https://at.alicdn.com/t/c/font_3712543_j9tx181l5x.css");
	/// 如果项目做好了 要上线了  这里引入本地的
</style>

